// JavaScript Document
var nbtnType = 0;// 初始化值
var nbtnPlace = 0;// 初始化值
var nbtnLatest = 0;// 初始化值
var nbtnSelect = 0;// 初始化值
$("#btnType").click(function() {
	if (nbtnType / 2 == 0) {
		$("#divTypeSource").show();
		$("#imgtype").attr("src", "../images/job/show.png");
		// 其他不显示
		$("#divPlaceSource").css("display", "none");
		$("#divLatestSource").css("display", "none");
		$("#divSelectSource").css("display", "none");
		$("#imgplace").attr("src", "../images/job/hide.png");
		$("#imglaster").attr("src", "../images/job/hide.png");
		$("#imgselect").attr("src", "../images/job/hide.png");
		nbtnType++;
		nbtnPlace = 0;
		nbtnLatest = 0;
		nbtnSelect = 0;
	} else {
		$("#divTypeSource").css("display", "none");
		$("#imgtype").attr("src", "../images/job/hide.png");
		nbtnType--;
	}
});

$("#btnPlace").click(function() {
	if (nbtnPlace / 2 == 0) {
		$("#imgplace").attr("src", "../images/job/show.png");
		$("#divPlaceSource").show();
		$("#divLatestSource").css("display", "none");
		$("#divSelectSource").css("display", "none");
		$("#divTypeSource").css("display", "none");
		$("#imgtype").attr("src", "../images/job/hide.png");
		$("#imglaster").attr("src", "../images/job/hide.png");
		$("#imgselect").attr("src", "../images/job/hide.png");
		nbtnPlace++;
		nbtnType = 0;
		nbtnLatest = 0;
		nbtnSelect = 0;
	} else {
		$("#divPlaceSource").css("display", "none");
		$("#imgplace").attr("src", "../images/job/hide.png");
		nbtnPlace--;
	}
});
$("#btnLatest").click(function() {
	if (nbtnLatest / 2 == 0) {
		$("#divLatestSource").show();
		$("#imglaster").attr("src", "../images/job/show.png");
		$("#divPlaceSource").css("display", "none");
		$("#divSelectSource").css("display", "none");
		$("#divTypeSource").css("display", "none");
		$("#imgtype").attr("src", "../images/job/hide.png");
		$("#imgplace").attr("src", "../images/job/hide.png");
		$("#imgselect").attr("src", "../images/job/hide.png");
		nbtnLatest++;
		nbtnType = 0;
		nbtnPlace = 0;
		nbtnSelect = 0;
	} else {
		$("#divLatestSource").css("display", "none");
		$("#imglaster").attr("src", "../images/job/hide.png");
		nbtnLatest--;
	}
});
$("#btnSelect").click(function() {
	if (nbtnSelect / 2 == 0) {
		$("#divSelectSource").show();
		$("#divPlaceSource").css("display", "none");
		$("#divLatestSource").css("display", "none");
		$("#divTypeSource").css("display", "none");
		$("#imgselect").attr("src", "../images/job/show.png");
		$("#imgtype").attr("src", "../images/job/hide.png");
		$("#imgplace").attr("src", "../images/job/hide.png");
		$("#imglaster").attr("src", "../images/job/hide.png");
		nbtnSelect++;
		nbtnType = 0;
		nbtnPlace = 0;
		nbtnLatest = 0;
	} else {
		$("#divSelectSource").css("display", "none");
		$("#imgselect").attr("src", "../images/job/hide.png");
		nbtnSelect--;
	}

});

// JavaScript Document

var strKeyWorld = "ch";
var strKeyType = "ch";
var num = 0;
// 全局变量
var getSex;
var getSummary;
var DeliveryValue;
var number = 0;// 参数值
function changeType(keyWorld, keyType) {
	changspan(keyWorld, keyType);// 改span值
	cshtbz();
	strKeyWorld = keyWorld;
	strKeyType = keyType;
	var strKey = keyWorld + "," + keyType + "," + num;
	$.ajax({
				type : "POST",
				url : "searchRecruitServlet.scx.szb",// 服务地址
				cache : false,
				data : "stringKey=" + strKey,
				dataType : 'json', // 返回值类型
				success : function(msg) {
					var cc = 0;
					for (i in msg) {
						cc++;
						var information = {
							recruitId : msg[i].recruitId,
							jobName : msg[i].jobName,
							reSalary : msg[i].reSalary,
							reSex : msg[i].reSex,
							reType : msg[i].reType,
							salaryType : msg[i].salaryType,
							issueDate : msg[i].issueDate
						};
						$("<li class='qkl'><a href='showInformation.jsp?/scx/123szb="
										+ information["recruitId"]
										+ "'>"
										+ "<div class='a_left'>"
										+ "<div class='ico'><img src='../images/menu/"
										+ information["reType"]
										+ "'/></div>"
										+ "</div>"
										+ " <div class='a_right' style='border-bottom:none;'>"
										+ " <h2>"
										+ information["jobName"]
										+ "</h2>"
										+ "<p class='place'> </p>" + " </div>"
										+ " </a> </li>").appendTo("#DataList");
					}
					if (cc != 10) {
						$("#bt").attr("value", "已全部加载");
					} else {
						$("#bt").attr("value", "加载更多");
					}
				},
				error : function() {
				}
			});
}
function datalist() {
	if (strKeyType != "ch" && strKeyWorld != "ch") {
		num = num + 10;
		changeType(strKeyWorld, strKeyType);
	} else {
		number = number + 10;
		link();
	}

}

// 点击li隐藏
$(".btnhidden").click(function() {
	$("#divSelectSource").css("display", "none");
	$("#divPlaceSource").css("display", "none");
	$("#divLatestSource").css("display", "none");
	$("#divTypeSource").css("display", "none");
	num = 0;
	$(".qkl").remove();
});
function GetRadioValue() {
	// 获取性别
	var groupsex = document.getElementsByName("groupsex");// 得到所有的性别标签
	if (groupsex != null) {
		var i;
		for (i = 0; i < groupsex.length; i++) {
			if (groupsex[i].checked) {
				getSex = groupsex[i].value;
			}
		}
	}
	// 获取结算方式
	var groupSummary = document.getElementsByName("groupSummary");
	if (groupSummary != null) {
		var i;
		for (i = 0; i < groupSummary.length; i++) {
			if (groupSummary[i].checked) {
				getSummary = groupSummary[i].value;
			}
		}
	}
}
// 判断定义是否获得值
function decide() {
	if (typeof (getSex) == "undefined") {
		DeliveryValue = getSummary;
	} else if (typeof (getSummary) == "undefined") {
		DeliveryValue = getSex;
	} else if (typeof (getSummary) != "undefined"
			&& typeof (getSex) != "undefined") {
		DeliveryValue = getSex + "," + getSummary;
	} else if (typeof (getSex) == "undefined"
			&& typeof (getSummary) == "undefined") {
	}
}
// 点击完成筛选
function finsh() {
	cshtbz();
	$(".qkl").remove();
	$(".sdd").remove();
	GetRadioValue();
	decide();
	link();
}

function link() {
	xs();
	GetRadioValue();
	decide();
	$.ajax({
				type : "POST", // 请求方式
				url : "multipleChoice.html", // 请求路径
				cache : false,
				data : "Value=" + DeliveryValue + "," + number, // 传参
				dataType : 'json', // 返回值类型
				success : function(msg) {
					var cc = 0;
					for (i in msg) {
						cc++;
						var information = {
							recruitId : msg[i].recruitId,
							jobName : msg[i].jobName,
							actType : msg[i].actType,
							reSalary : msg[i].reSalary,
							reSex : msg[i].reSex,
							reType : msg[i].reType,
							salaryType:msg[i].salaryType
						};
						$(
								"<li class='sdd'><a href='showInformation.jsp?/scx/123szb="
										+ information["recruitId"]
										+ "'>"
										+ "<div class='a_left'>"
										+ "<div class='ico'><img src='../images/menu/"
										+ information["reType"]
										+ "'/></div>"
										+ "</div>"
										+ " <div class='a_right' style='border-bottom:none;'>"
										+ " <h2>"
										+ information["jobName"]
										+ "</h2>"
										+ " <p><em>放心</em><em>"
										+ information["reSex"]
										+ "</em><em>"
										+ information["actType"]
										+ "</em></p>"
										+ "<p class='place'> <em class='a_right local' style='border-bottom: none; background:none; width: 10%; padding-left: 4%; margin-right: 0;'></em> "
										+ "<em style=' background:none;padding-left: 5%; '>2015-07-28</em> <b><strong>"
										+ information["reSalary"]
										+ "</strong>元/"+information["salaryType"]+"</b> </p>" + " </div>"
										+ " </a> </li>").appendTo("#DataList");
					}
					if (cc != 10) {
						$("#bt").attr("value", "已全部加载");
					} else {
						$("#bt").attr("value", "加载更多");
					}
				},
				error : function() {
				}
			});
}
// 点击消失
function xs() {
	$("#divSelectSource").css("display", "none");
}
// 点击后初始化值
function cshtbz() {
	$("#divPlaceSource").css("display", "none");
	$("#divLatestSource").css("display", "none");
	$("#divSelectSource").css("display", "none");
	$("#divTypeSource").css("display", "none");
	$("#imgplace").attr("src", "../images/job/hide.png");
	$("#imgtype").attr("src", "../images/job/hide.png");
	$("#imglaster").attr("src", "../images/job/hide.png");
	$("#imgselect").attr("src", "../images/job/hide.png");
	nbtnPlace = 0;
	nbtnType = 0;
	nbtnLatest = 0;
	nbtnSelect = 0;
}
// 改变span标签的值
function changspan(keyWorld, keyType) {
	var world = keyWorld;
	var type = keyType;
	if (world == "alltype") {
		document.getElementById("cx").innerHTML = "全部菜系";
		document.getElementById("fb").innerHTML = "最新发布";
	}
	if (world == "reType") {
		if (keyType == "su.png")
			document.getElementById("cx").innerHTML = "苏菜";
		if (keyType == "yue.png")
			document.getElementById("cx").innerHTML = "粤菜";
		if (keyType == "lu.png")
			document.getElementById("cx").innerHTML = "鲁菜";
		if (keyType == "hui.png")
			document.getElementById("cx").innerHTML = "徽菜";
		if (keyType == "zhe.png")
			document.getElementById("cx").innerHTML = "浙菜";
		if (keyType == "min.png")
			document.getElementById("cx").innerHTML = "闽菜";
		if (keyType == "xiang.png")
			document.getElementById("cx").innerHTML = "湘菜";
		if (keyType == "chu.png")
			document.getElementById("cx").innerHTML = "川菜";
		if (keyType == "gd.png")
			document.getElementById("cx").innerHTML = "更多";
		document.getElementById("fb").innerHTML = "最新发布";
	}
	if (world == "payment") {
		if (keyType == "alltype")
			document.getElementById("fb").innerHTML = "最新发布";
		document.getElementById("cx").innerHTML = "全部菜系";
	}
}
